using System;
using System.Data;
using System.Collections;

namespace RMAS.DAL
{
    /// <summary>
    /// Summary description for QT_PROMOTION.
    /// </summary>
    public class QT_PROMOTIONList : CollectionBase
    {
		private string _ErrMsg;
        public string ErrMsg { get { return _ErrMsg; } }
    	public QT_PROMOTIONList()
    	{
	    }

		public void Add(QT_PROMOTION entity)
		{
            this.List.Add(entity);
		}

		public void Add(QT_PROMOTIONList list)
		{	
			foreach(QT_PROMOTION entity in list)
			{
				this.Add(entity);
			}
		}
	
		public new virtual Enumerator GetEnumerator()
		{
		    return new Enumerator(this);
		}
		public virtual QT_PROMOTION this[int index]
		{
		    get
			{
				return (QT_PROMOTION)this.List[index];
			}
			set
			{
				this.List[index] = value;
			}
		}

		#region Find Object And List Object
		//---PrimaryKey
	public virtual QT_PROMOTION Find(string ID)
	{
	    foreach (QT_PROMOTION obj in this.List)
	    {
		if(obj.ID.ToString().ToUpper().Trim() == ID.ToString().ToUpper().Trim())
		{
		    obj.IsExisting = true;
		    return obj;
		}
	    }
	    return null;
	}

public virtual QT_PROMOTIONList FindListByID(string ID)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
		    if(obj.ID.ToString().ToUpper().Trim() == ID.ToString().ToUpper().Trim())
		    {
				List.Add(obj);
		    }
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
    	{
		_ErrMsg = ex.Message;
        		return null;
    	}
}
		//---NonPrimaryKey
        public virtual QT_PROMOTION FindByName(string Name)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.Name.ToString().ToUpper().Trim() == Name.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual QT_PROMOTION FindByDiscountMoney(decimal DiscountMoney)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.DiscountMoney.ToString().ToUpper().Trim() == DiscountMoney.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual QT_PROMOTION FindByDiscountPercent(double DiscountPercent)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.DiscountPercent.ToString().ToUpper().Trim() == DiscountPercent.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual QT_PROMOTION FindByDateBegin(DateTime DateBegin)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.DateBegin.ToString().ToUpper().Trim() == DateBegin.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual QT_PROMOTION FindByDateEnd(DateTime DateEnd)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.DateEnd.ToString().ToUpper().Trim() == DateEnd.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual QT_PROMOTION FindByTypeDiscount(string TypeDiscount)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.TypeDiscount.ToString().ToUpper().Trim() == TypeDiscount.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual QT_PROMOTION FindByDateCreate(DateTime DateCreate)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.DateCreate.ToString().ToUpper().Trim() == DateCreate.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual QT_PROMOTION FindByUserName(string UserName)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.UserName.ToString().ToUpper().Trim() == UserName.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual QT_PROMOTION FindByIsUse(bool IsUse)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.IsUse.ToString().ToUpper().Trim() == IsUse.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual QT_PROMOTION FindByIsEnd(bool IsEnd)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.IsEnd.ToString().ToUpper().Trim() == IsEnd.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual QT_PROMOTION FindByNote(string Note)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.Note.ToString().ToUpper().Trim() == Note.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual QT_PROMOTION FindByIDPOS(string IDPOS)
        {
	        foreach (QT_PROMOTION obj in this.List)
	        {
		        if(obj.IDPOS.ToString().ToUpper().Trim() == IDPOS.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

public virtual QT_PROMOTIONList FindListByName(string Name)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.Name.ToString().ToUpper().Trim() == Name.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual QT_PROMOTIONList FindListByDiscountMoney(decimal DiscountMoney)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.DiscountMoney.ToString().ToUpper().Trim() == DiscountMoney.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual QT_PROMOTIONList FindListByDiscountPercent(double DiscountPercent)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.DiscountPercent.ToString().ToUpper().Trim() == DiscountPercent.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual QT_PROMOTIONList FindListByDateBegin(DateTime DateBegin)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.DateBegin.ToString().ToUpper().Trim() == DateBegin.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual QT_PROMOTIONList FindListByDateEnd(DateTime DateEnd)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.DateEnd.ToString().ToUpper().Trim() == DateEnd.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual QT_PROMOTIONList FindListByTypeDiscount(string TypeDiscount)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.TypeDiscount.ToString().ToUpper().Trim() == TypeDiscount.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual QT_PROMOTIONList FindListByDateCreate(DateTime DateCreate)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.DateCreate.ToString().ToUpper().Trim() == DateCreate.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual QT_PROMOTIONList FindListByUserName(string UserName)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.UserName.ToString().ToUpper().Trim() == UserName.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual QT_PROMOTIONList FindListByIsUse(bool IsUse)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.IsUse.ToString().ToUpper().Trim() == IsUse.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual QT_PROMOTIONList FindListByIsEnd(bool IsEnd)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.IsEnd.ToString().ToUpper().Trim() == IsEnd.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual QT_PROMOTIONList FindListByNote(string Note)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.Note.ToString().ToUpper().Trim() == Note.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual QT_PROMOTIONList FindListByIDPOS(string IDPOS)
{
	try
	{
		QT_PROMOTIONList List = new QT_PROMOTIONList();
		foreach (QT_PROMOTION obj in this.List)
		{
			if(obj.IDPOS.ToString().ToUpper().Trim() == IDPOS.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}
		#endregion
     
		#region Inner Classes
		/// <summary>
		/// Type-specific enumeration class, used by LogCollection.GetEnumerator.
		/// </summary>
		public class Enumerator : IEnumerator
		{
			private IEnumerator wrapped;

			public Enumerator(QT_PROMOTIONList collection)
			{
				this.wrapped = ((CollectionBase)collection).GetEnumerator();
			}

			public QT_PROMOTION Current
			{
				get
				{
					return (QT_PROMOTION)(this.wrapped.Current);
				}
			}

			object IEnumerator.Current
			{
				get
				{
					return (QT_PROMOTION)(this.wrapped.Current);
				}
			}

			public bool MoveNext()
			{
				return this.wrapped.MoveNext();
			}

			public void Reset()
			{
				this.wrapped.Reset();
			}
      }
      #endregion  
   }
}